<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="dao.Products"%> 
<%@page import="model.ProductModel"%> 
<%@page import="java.util.List" %>  
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>

<body>
	<% 	String id = (String)request.getParameter("id"); 
		Products proDTO = new Products(); // edit case
		List<ProductModel> model = proDTO.getProducts(id, null, null, null);
		String imgName = model.size() == 0 ? "" : model.get(0).getImage_url() ;
		String Url = request.getContextPath() + "/img/upload/" + imgName;
		session.setAttribute("product_id", id);
		
		%>
	<form action="UploadImage" method="post" enctype="multipart/form-data"><br><br>
		<img alt="" src="<%=Url%>" width="150px" height="150px">
		<input type="hidden" name="product_id" value="<%=id%>"/>
		<table width="400px" align="center" border=0 style="background-color:ffeeff;">
			<tr>
				<td align="center" colspan=2 style="font-weight:bold;font-size:20pt;">Image Upload</td>
			</tr>

			<tr>
				<td align="center" colspan=2>&nbsp;</td>
			</tr>

			<tr>
				<td>Image Link: </td>
				<td>
					<input type="file" name="file" id="file" value="">
				<td>
			</tr>

			<tr>
				<td></td>
				<td><input type="submit" name="Submit" value="Submit"></td>
			</tr>
			<tr>
				<td colspan="2">&nbsp;</td>
			</tr>
		</table>
	</form>
</body>
</html>